﻿#ifndef DLGCUBE_H
#define DLGCUBE_H

#include "geometryengine.h"

#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include <QMatrix4x4>
#include <QQuaternion>
#include <QVector2D>
#include <QBasicTimer>
#include <QOpenGLShaderProgram>
#include <QOpenGLTexture>
#include <QDebug>

class GeometryEngine;

class DlgCube: public QOpenGLWidget, protected QOpenGLFunctions
{
    Q_OBJECT
public:
    explicit DlgCube(int width, int height, QWidget *parent = 0);
    ~DlgCube();

    void InitCube();
    void MoveLittle();
    QPen random_Color();
    int random_fontpixsize(int fontlen);
    void initTextures();
private:
    QImage Text_To_Image(int count);
protected:
    void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
    void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
    void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE;

    void initializeGL() Q_DECL_OVERRIDE;
    void resizeGL(int w, int h) Q_DECL_OVERRIDE;
    void paintGL() Q_DECL_OVERRIDE;

    void initShaders();

private:
    QBasicTimer timer;
    QOpenGLShaderProgram program;
    GeometryEngine *geometries;

    QOpenGLTexture *texture;

    QMatrix4x4 projection;

    QVector2D mousePressPosition;
    QVector3D rotationAxis;
    qreal angularSpeed;
    QQuaternion rotation;

    QImage  myImage;
    int     m_which_color;

    QVector <QString> tip_1;
    QVector <QString> tip_2;
    QVector <QString> tip_3;
    QVector <QString> tip_4;
    QVector <QString> tip_5;
    QVector <QString> tip_6;
};

#endif // DLGCUBE_H
